package edu.calvin.djs32.cs214.interpreters;

import org.junit.Test;
import org.norecess.antlr.ANTLRTester;
import static org.norecess.antlr.Assert.assertToken;

public class Hobbes2008LexerTest {

	@Test
	public void shouldRecognizeIntegers() {
		ANTLRTester tester = new ANTLRTester(new Hobbes2008FrontEnd());
		assertToken(Hobbes2008Lexer.INTEGER, "1", tester.scanInput("1"));
		assertToken(Hobbes2008Lexer.INTEGER, "4", tester.scanInput("4"));
		assertToken(Hobbes2008Lexer.INTEGER, "9", tester.scanInput("9"));
		assertToken(Hobbes2008Lexer.INTEGER, "12", tester.scanInput("12"));
		assertToken(Hobbes2008Lexer.INTEGER, "123", tester.scanInput("123"));
		assertToken(Hobbes2008Lexer.INTEGER, "-123", tester.scanInput("-123"));
		assertToken(Hobbes2008Lexer.INTEGER, "-4568", tester.scanInput("-4568"));
		assertToken(Hobbes2008Lexer.INTEGER, "+123", tester.scanInput("+123"));
	}
	
	@Test
	public void shouldIgnoreWhitespace() {
	  ANTLRTester tester = new ANTLRTester(new Hobbes2008FrontEnd());
	  assertToken(Hobbes2008Lexer.INTEGER, "1", tester.scanInput("1 "));
	  assertToken(Hobbes2008Lexer.INTEGER, "4", tester.scanInput(" 4"));
	  assertToken(Hobbes2008Lexer.INTEGER, "123", tester.scanInput("  123"));
	  assertToken(Hobbes2008Lexer.INTEGER, "9", tester.scanInput("  9"));
	  assertToken(Hobbes2008Lexer.INTEGER, "8", tester.scanInput(" 8 "));
	  assertToken(Hobbes2008Lexer.INTEGER, "8", tester.scanInput("\t8"));               
	  assertToken(Hobbes2008Lexer.INTEGER, "8", tester.scanInput("\n8"));         
	  assertToken(Hobbes2008Lexer.INTEGER, "8", tester.scanInput(" \t\n8 "));
	}
	@Test
	public void shouldIgnoreComments() {
	  ANTLRTester tester = new ANTLRTester(new Hobbes2008FrontEnd());
	  assertToken(Hobbes2008Lexer.INTEGER, "1", tester.scanInput("/* fweafea */ \n 1"));
	  assertToken(Hobbes2008Lexer.INTEGER, "1", tester.scanInput("1 //do this work \n"));

	}
	
	@Test
	public void shouldIgnoreHexadecimal() {
		ANTLRTester tester = new ANTLRTester(new Hobbes2008FrontEnd());
		assertToken(Hobbes2008Lexer.INTEGER, "0x123f", tester.scanInput("0x123f"));
		assertToken(Hobbes2008Lexer.INTEGER, "-0x123f", tester.scanInput("-0x123f"));
		assertToken(Hobbes2008Lexer.INTEGER, "+0x123f", tester.scanInput("+0x123f"));
	}
	
}